<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/WEB-INF/facelets/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:param name="title" value="Add product"/>
    <ui:define name="form">
        <h:form>
            <p:panel id="namePanel">
                <h:panelGrid id="grid" columns="3">
                    <h:outputLabel for="productName" value="Product Name:"/>
                    <h:inputText id="productName" value="#{addProductControllerBean.product.name}" 
                                 required="true" requiredMessage="Can't be empty" >
                        <f:validateLength minimum="3" />
                        <f:ajax event="blur" render="pMsg" />
                    </h:inputText>
                    <p:message id="pMsg" for="productName" display="text"/>                

                    <h:outputLabel for="productCategory" value="Product Category:"/>
                    <h:inputText id="productCategory" value="#{addProductControllerBean.product.cat}"/>
                    <p></p>
                    
                    <h:outputLabel for="productPrice" value="Price:"/>
                    <h:inputText id="productPrice" value="#{addProductControllerBean.product.price}" 
                                 required="true" requiredMessage="Can't be empty"
                                 validatorMessage="Must be 1-8 chars">
                        <f:validateDoubleRange for="productPrice" minimum="0">
                        <f:ajax event="blur" render="prMsg" />
                        </f:validateDoubleRange>
                    </h:inputText>
                    <p:message id="prMsg" for="productPrice" display="text" showSummary="true" showDetail="false" />                

                </h:panelGrid>
            </p:panel>
            <p>
                <p:commandButton value="Add Product" id="submit" update="@namePanel" ajax="false"
                   action="#{addProductControllerBean.addProduct()}" />
            </p>
            
        </h:form>
    </ui:define>
    <ui:param name="h1" value="Add product"/>

</ui:composition>